package com.xiaodou.mjf.web.console.staging.controller;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xiaodou.mjf.application.basic.repository.mybatis.AccountFeeMapper;
import com.xiaodou.mjf.application.fee.service.AccountFeeService;
import com.xiaodou.mjf.entity.fee.AccountFee;
import com.xiaodou.mjf.infrastructure.common.controller.ApplicationController;

/**
 * 最近还款Controller
 * 
 * @author wangyinhua
 *
 */
@Controller
@RequestMapping("staging/recent/repayment")
public class RecentRepaymentController extends ApplicationController {

	@Resource
	AccountFeeService accountFeeService;
	@Resource
	AccountFeeMapper accountFeeMapper;
	
	@RequestMapping("")
	public String apply(AccountFee accountFee) {

		return "staging/recent/list";
	}

	@RequestMapping(value = { "data.json" })
	@ResponseBody
	public Map<String, Object> data(AccountFee accountFee) {
		accountFee.setRepaymentStatus(AccountFee.REPAYMENT_STATUS_0);
		if(accountFee.getStart()==1) {
			accountFee.setStart(0);
		} else {
			accountFee.setStart(accountFee.getStart()-1);
		}
		List<AccountFee> acf = accountFeeMapper.getAllFeeList(accountFee);
		accountFee.setRepaymentStatus(AccountFee.REPAYMENT_STATUS_0);
		Integer count = accountFeeMapper.getTotalCount(accountFee);
		return page(count, acf);
	}

}
